﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace Latarka
{
    public partial class Form1 : Form
    {
        [DllImport("SamsungMobileSDK_1.dll")]
        static extern void SmiCameraFlashTurnOn();

        [DllImport("SamsungMobileSDK_1.dll")]
        static extern void SmiCameraFlashTurnOff();

        byte czas;

        public Form1()
        {
            InitializeComponent();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            SmiCameraFlashTurnOn();
            timer1.Enabled = true;
            czas = 60;
        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {
            SmiCameraFlashTurnOff();
            timer1.Enabled = false;
            czas = 60;
            label5.Text = "Latarka wyłączy się po: " + czas.ToString() + " sek.";
        }

        private void menuItem1_Click(object sender, EventArgs e)
        {
            SmiCameraFlashTurnOff();
            Application.Exit();
        }

        private void Form1_Closed(object sender, EventArgs e)
        {
            SmiCameraFlashTurnOff();
        }

        private void menuItem2_Click(object sender, EventArgs e)
        {
            About about = new About();
            about.Show();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            czas--;
            label5.Text = "Latarka wyłączy się po: " + czas.ToString() + " sek.";
            if (czas == 0)
            {
                SmiCameraFlashTurnOff();
                timer1.Enabled = false;
            }
        }
    }
}